import emitter from '#/utils/events';

export const HANDLE_ENUM = {
  SUB_MENU_CODE: 'subMenuCode', //根据统计时长的menucode
  SUB_CHECK_CODE: 'subCheckFeed', //统计
  SUB_LOGOUT: 'subLogout', //统计
  SUB_HISTORY: 'subHistory', // 跳转页面
  SUB_AMAP: 'subAmap', // 加载地图
  SUB_MICRO: 'subMicro', // 加载其他子项目
  SUB_MICRO_CLOSE: 'subMicroClose', // 关闭其他子项目
  SUB_RENOVATE: 'subRenovate', // 关闭其他子项目
  CHANGE_THEME: 'changeTheme', // 切换主题
};

export const onCheckFeed = function (data) {
  emitter.emit('onInteractive', { type: HANDLE_ENUM.SUB_CHECK_CODE, data: data });
};

export const OnSubChangeMenuCode = function (data) {
  emitter.emit('onInteractive', { type: HANDLE_ENUM.SUB_CHECK_CODE, data: data });
};

export const OnSubLogout = function (data) {
  emitter.emit('onInteractive', { type: HANDLE_ENUM.SUB_LOGOUT, data: data });
};

export const OnHistory = function (data) {
  emitter.emit('onInteractive', { type: HANDLE_ENUM.SUB_HISTORY, data: data });
};

export const OnLoadAmap = function (data, callBack) {
  emitter.emit('onInteractive', { type: HANDLE_ENUM.SUB_AMAP, data: data, callBack });
};

export const OnLoadSubMicro = function (data, callBack) {
  emitter.emit('onInteractive', { type: HANDLE_ENUM.SUB_MICRO, data: data, callBack });
};

export const OnMicroClose = function (data) {
  emitter.emit('onInteractive', { type: HANDLE_ENUM.SUB_MICRO_CLOSE, data: data });
};

export const OnRenovate = function (data) {
  emitter.emit('onInteractive', { type: HANDLE_ENUM.SUB_RENOVATE, data: data });
};

export const OnChangeTheme = (theme) => {
  emitter.emit('onInteractive', { type: HANDLE_ENUM.CHANGE_THEME, data: { theme } });
};
